/*
 * Copyright (c) 2006-2025, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2025-06-23     RT-Thread    first version
 */

#include <rtthread.h>
#include <lcd_st7735s.h>
#include <RGB_LED.h>
#include <bsp.h>
#include <INA226_I2C.h>

// LED 闪烁函数
static void led_blink(void)
{
    static int state = 0;
    if (state == 0)
    {
        led_control(LED_R_PIN, 0); // 点亮LED
    }
    else
    {
        led_control(LED_R_PIN, 1); // 熄灭LED
    }
    state = !state; // 切换状态
}
//屏幕框图绘画//
void lcd_init_fill(void)
{

    LCD_DrawRectangle(2,2,157, 77,GREEN);
    LCD_DrawLine(2,27,157,27, GREEN);
    LCD_DrawLine(2,52,157,52, GREEN);
    LCD_DrawLine(27,27,27,77, GREEN);
    LCD_DrawLine(132,27,132,77, GREEN);
//    LCD_DrawLine(60,2,60,27, GREEN);
//    LCD_DrawLine(108,2,108,27, GREEN);

    LCD_ShowString(3,3, 24*3, 24, 24, "C1", DARKBLUE, BRED);
    LCD_ShowString(28,3, 24*6, 24, 24, "DCAmmeter", DARKBLUE, GRAY);
    LCD_ShowString(136,3, 24*2, 24, 24, "5V", DARKBLUE, YELLOW);
    LCD_ShowString(10,28, 24, 24, 24, "I", DARKBLUE, WHITE);
    LCD_ShowString(10,53, 24, 24, 24, "U", DARKBLUE, WHITE);
    LCD_ShowString(138,28, 32, 24, 16, "mA", DARKBLUE, WHITE);
    LCD_ShowString(140,53, 24, 24, 24, "v", DARKBLUE, WHITE);

}

int main(void)
{
//    uint32_t count = 1 ;
 //   led_init();
    bsp_init();
    lcdInit();
    LCD_DisplayOn(); //开显示
    lcdClear(WHITE);
    lcd_init_fill();
    INA226_INIT();
    bsp_thread_init();



    while (1)
    {
        led_blink();
        rt_thread_mdelay(1000);
    }

    return RT_EOK;
}
